# frozen_string_literal: true
class ApplicationController < ActionController::Base
  layout 'layouts/application'

  before_action :check_auth

  include Pundit
  include ParamsPlugin

  def pundit_user
    current_editor
  end

  def current_editor
    puts "get current"
    puts session
    @current_editor ||= Editor.where(telephone: session[:editor_telephone]).first
  end

  def check_auth
    puts "get current"
    puts session
    @current_editor ||= Editor.where(telephone: session[:editor_telephone]).first
    redirect_to new_session_path if @current_editor.blank?
  end
end
